package com.witdata.controller.community;

import com.witdata.common.domain.Result;
import com.witdata.common.domain.Status;
import com.witdata.common.domain.dto.CommentLikeDto;
import com.witdata.common.service.community.CommentLikeService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author LiuQi
 */
@RestController
@RequestMapping("/community/comment/like")
@RequiredArgsConstructor
public class CommentLikeController {
    private final CommentLikeService commentLikeService;
    /**
     * 点赞
     */
    @PostMapping("/publish")
    public Result<String> likeComment(@RequestParam("commentId")Long commentId) {
        commentLikeService.likeComment(commentId);
        return Result.ok(Status.LIKESUCCESS);
    }
    /**
     * 取消点赞
     */
    @PostMapping("/cancel")
    public Result<String> unlikeComment(@RequestParam("commentId")Long commentId) {
        commentLikeService.unlikeComment(commentId);
        return Result.ok(Status.CANCELSUCCESS);
    }
    /**
     * 获取用户点赞列表
     */
    @PostMapping("/list")
    public Result <List<CommentLikeDto>> getCommentLikeList() {
        List<CommentLikeDto> commentLikeList = commentLikeService.getCommentLikeList();
        return Result.ok(Status.SUCCESS, commentLikeList);
    }
}
